window.addEventListener("load", function() {
  // Buttons are members of the UIItem family.
  // Firstly we set some properties to apply to the button.
  var UIItemProperties = {
    disabled: true, // The button is enabled.
    title: "My IMFU", // The tooltip title.
    icon: "mainicon.png", // The icon (18x18) to use for the button.
    popup: {
      href: "main.html",
      width: "415px",
      height: "610px"
    }
  };

  // Next, we create the button and apply the above properties.
  var button = opera.contexts.toolbar.createItem(UIItemProperties);
  // Finally, we add the button to the toolbar.
  opera.contexts.toolbar.addItem(button);
  
function enableButton() {
    var tab = opera.extension.tabs.getFocused();
    if (tab) {
      button.disabled = false;
    } else {
      button.disabled = true;
    }
  }
	
  // Enable the button when a tab is ready.
  opera.extension.onconnect = enableButton;
  opera.extension.tabs.onfocus = enableButton;
  opera.extension.tabs.onblur = enableButton;  
}, false);


function opentab2(evt,e,addy){
    if (e.which == 1){	var tab = opera.extension.tabs.getFocused();
			if (tab)
    			tab.update({ url: addy });}
    else if (e.which == 2){opera.extension.tabs.create({"url":addy,"focused":true});}}